/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.insurance.cis.models;

import com.insurance.cis.daos.CategoryDao;
import java.util.Objects;

/**
 *
 * @author Thuy Truc
 */
public class ProductCategory {
    Integer productID;
    String productCatDesc;
    public ProductCategory(Integer id, String desc) {
        productID =id;
        productCatDesc=desc;
    }

    public int getProductID() {
        return productID;
    }

    @Override
    public String toString() {
        return productCatDesc;
    }

    public Integer getId() {
        return productID;
    }

    public void setId(Integer id) {
        this.productID = id;
    }

    CategoryDao categoryDao = new CategoryDao();
    public String getDesc() {
        if (this.productCatDesc ==null
                || productCatDesc.isEmpty()) {
            if (productID == null) {
                return productCatDesc;
            }
            ProductCategory category=categoryDao.getProductCategoryByID(productID);
            if (category!=null) {
                productCatDesc = category.getDesc();
            }
        } 
        return productCatDesc;
    }

    public void setDesc(String desc) {
        this.productCatDesc = desc;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ProductCategory other = (ProductCategory) obj;
        if (!Objects.equals(this.productCatDesc, other.productCatDesc)) {
            return false;
        }
        return true;
    }

    
}
